package com.grt.condify.reflect;

import com.grt.condify.utils.StringUtil;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.List;


/**
 * 注解对应的Field缓存
 * *@author:wen.wen
 * *@create 2020-07-02 16:10
 **/
public class Class2Annotation2FieldInNoStaticCache extends Class2MapInNonStaticCache<String, Class<? extends Annotation>, List<Field>> {

    @Override
    public boolean isKeyEmpty(String key) {
        return StringUtil.isEmpty(key);
    }

    @Override
    public boolean isKeyOfMapEmpty(Class<? extends Annotation> keyOfMap) {
        return keyOfMap == null;
    }

    @Override
    public boolean isValueIsEmpty(List<Field> value) {
        return value == null || value.size() <= 0;
    }

    public List<Field> getFieldsWithAnnotation(String className, Class<? extends Annotation> annotationClass) {
        if (StringUtil.isEmpty(className) || annotationClass == null) {
            return null;
        }
        return isContain(className) ? firstLevelCaches.get(className).get(annotationClass) : null;
    }

}
